package com.fish.common.tag;

import java.util.List;

/**
 *分页对象
 * 
 * @author clj
 * 
 * @param <T>
 *            数据类型
 */
public class Pager<T> {

	private int page;// 当前页
	private int pageSize;// 每页多少条
	private int count;// 总记录
	private List<T> data;// 数据

	public Pager() {
	}

	public Pager(int _page, int _pageSize, int _count) {
		this.page = _page > 0 ? _page : 0;
		this.pageSize = (_pageSize > 0 ? _pageSize : 20);
		this.count = _count > 0 ? _count : 0;
	}

	public Pager<T> setPage(int _page, int _pageSize, int _count) {
		this.page = _page > 0 ? _page : 0;
		this.pageSize = (_pageSize > 0 ? _pageSize : 20);
		this.count = _count > 0 ? _count : 0;
		return this;
	}

	public int getPageCount() {
		return (count + pageSize - 1) / pageSize;
	}

	public int getPage() {
		return page;
	}

	public int getPageSize() {
		return pageSize;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	/**
	 * 起始记录
	 */
	public int getFirstResult() {
		return (page - 1) * pageSize;

	}

	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

}
